import React from 'react'
import {postSofContractUpdateCp} from '../../../Api'
import { Modal, Form, DatePicker, InputNumber, message } from 'antd'
import moment from 'moment'

const ChangeModule = ({ changeModuleShow, setChangeModuleShow, clickId, listFun }) => {
    const [form] = Form.useForm()
    const {validateFields} = form
    const handleOk = () => {
        validateFields().then(values => {
            values.enterDate = moment(values.enterDate).format('YYYY-MM-DD')
            values.id = clickId
            ;(async () => {
                const {code, msg } = await postSofContractUpdateCp(values);
                if(code === "20000") {
                    message.success("编辑成功")
                    listFun();
                    setChangeModuleShow(false);
                }else{
                    message.error(msg);
                }
            })()
        })
        // 
    };

    const handleCancel = () => {
        setChangeModuleShow(false);
    };
    return <Modal title="编辑" visible={changeModuleShow} onOk={handleOk} onCancel={handleCancel}>
        <Form
            labelCol={{ span: 8 }}
            wrapperCol={{ span: 16 }}
            form = {form}
        >
            <Form.Item
                label="出账时间"
                name="enterDate"
                rules={[{ required: true, message: '请选择出账时间!' }]}
            >
                <DatePicker />
            </Form.Item>
            <Form.Item
                label="应收金额"
                name="ribAccounts"
                rules={[{ required: true, message: '请输入应收金额!' }]}
            >
                <InputNumber />
            </Form.Item>


        </Form>
    </Modal>
}

export default ChangeModule